﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace UBCon.Core.Models
{
    public class DraggableControlModel
    {
        #region Private Fields

        private Point beginPoint, endPoint;

        private double xLocation = -1.0D, yLocation = -1.0D;

        private UIElement uiElement;

        private int index = -1;

        #endregion

        #region Properties


        /// <summary>
        /// Gets or sets changed Index not actual index.
        /// </summary>
        public int Index
        {
            get
            {
                return index;
            }
            set
            {
                index = value;
            }
        }
        /// <summary>
        /// Gets or sets start point of control.
        /// </summary>
        public Point BeginPoint
        {
            get
            {
                return beginPoint;
            }
            set
            {
                beginPoint = value;
            }
        }

        /// <summary>
        /// Gets or sets end point of control.
        /// </summary>
        public Point EndPoint
        {
            get
            {
                return endPoint;
            }
            set
            {
                endPoint = value;
            }
        }

        /// <summary>
        /// Get or sets associated uielement.
        /// </summary>
        /// 
        public UIElement UIElement
        {
            get
            {
                return uiElement;
            }
            set
            {
                uiElement = value;
            }
        }

        /// <summary>
        /// Gets or sets x coordinate of uielement.
        /// </summary>
        public double XLocation
        {
            get
            {
                return xLocation;
            }
            set
            {
                if (value != xLocation
                    && UIElement != null)
                {
                    BeginPoint = new Point(value, YLocation);

                    EndPoint = new Point(BeginPoint.X + UIElement.DesiredSize.Width, BeginPoint.Y + UIElement.DesiredSize.Height);
                }
                xLocation = value;

            }
        }

        /// <summary>
        /// Gets or sets y coordinate of uielement.
        /// </summary>
        public double YLocation
        {
            get
            {
                return yLocation;
            }
            set
            {
                if (value != yLocation
                    && UIElement != null)
                {
                    BeginPoint = new Point(XLocation, value);
                    EndPoint = new Point(BeginPoint.X + UIElement.DesiredSize.Width, BeginPoint.Y + UIElement.DesiredSize.Height);
                }

                yLocation = value;
            }
        }

        #endregion
    }
}
